import re
import argparse

def split_regex(file: str, pattern: str):
  with open(file, "rb") as f:
        data = f.read().decode('utf-8')
        # pattern = r'\u7b2c[\u96f6|\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341|\u767e|\u5343]+\u7ae0'
        paragraphs = re.split(pattern, data)
        print(len(paragraphs))
        # texts = paragraphs[:10]
        # for text in texts:
        #   print(text)
        return paragraphs
        
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("file")
    parser.add_argument("--pattern", required=True)
    args = parser.parse_args()
    split_regex(**vars(args))